{%- set ipv6_enabled = salt['omv_utils.is_ipv6_enabled']() -%}
{%- set general_uid = salt['pillar.get']('default:OMV_FORKEDDAAPD_GENERAL_UID', 'daapd') -%}
{%- set general_logfile = salt['pillar.get']('default:OMV_FORKEDDAAPD_GENERAL_LOGFILE', '/var/log/forked-daapd.log') -%}
{%- set general_loglevel = salt['pillar.get']('default:OMV_FORKEDDAAPD_GENERAL_LOGLEVEL', 'log') -%}
{%- set general_db_path = salt['pillar.get']('default:OMV_FORKEDDAAPD_GENERAL_DBPATH', '/var/cache/forked-daapd/songs3.db') -%}
{%- set library_filescan_disable = salt['pillar.get']('default:OMV_FORKEDDAAPD_LIBRARY_FILESCANDISABLE', 'false') -%}
{%- set library_itunes_overrides = salt['pillar.get']('default:OMV_FORKEDDAAPD_LIBRARY_ITUNESOVERRIDES', 'false') -%}
{%- set audio_nickname = salt['pillar.get']('default:OMV_FORKEDDAAPD_AUDIO_NICKNAME', 'Computer') -%}
{%- set audio_type = salt['pillar.get']('default:OMV_FORKEDDAAPD_AUDIO_TYPE', 'dummy') -%}
{%- set mpd_port = salt['pillar.get']('default:OMV_FORKEDDAAPD_MPD_PORT', '0') -%}
{{ pillar['headers']['multiline'] -}}
general {
    # Username
    uid = "{{ general_uid }}"

    # Database location
    db_path = "{{ general_db_path }}"

    # Log file and level
    # Available levels: fatal, log, warning, info, debug, spam
    logfile = "{{ general_logfile }}"
    loglevel = "{{ general_loglevel }}"

    # Admin password for the non-existent web interface
    admin_password = "{{ config.adminpassword }}"

    # Enable/disable IPv6
    ipv6 = {{ "yes" if ipv6_enabled else "no"  }}

    # Location of cache database
#   cache_path = "/var/cache/forked-daapd/cache.db"

    # DAAP requests that take longer than this threshold (in msec) get their
    # replies cached for next time. Set to 0 to disable caching.
#   cache_daap_threshold = 1000

    # When starting playback, autoselect speaker (if none of the previously
    # selected speakers/outputs are available)
#   speaker_autoselect = yes
}

# Library configuration
library {
    # Name of the library as displayed by the clients
    # %h: hostname, %v: version
    name = "{{ config.libraryname }}"

    # TCP port to listen on. Default port is 3689 (daap)
    port = {{ config.port }}

    # Password for the library. Optional.
{%- if config.passwordrequired | to_bool %}
    password = "{{ config.password }}"
{%- else %}
#   password = ""
{%- endif %}

    # Directories to index
    directories = { "{{ salt['omv_conf.get_sharedfolder_path'](config.sharedfolderref) }}" }

    # Directories containing podcasts
    # For each directory that is indexed the path is matched against these
    # names. If there is a match all items in the directory are marked as
    # podcasts. Eg. if you index /srv/music, and your podcasts are in
    # /srv/music/Podcasts, you can set this to "/Podcasts".
    # (changing this setting only takes effect after rescan, see the README)
    podcasts = { "/Podcasts" }

    # Directories containing audiobooks
    # For each directory that is indexed the path is matched against these
    # names. If there is a match all items in the directory are marked as
    # audiobooks.
    # (changing this setting only takes effect after rescan, see the README)
    audiobooks = { "/Audiobooks" }

    # Directories containing compilations (eg soundtracks)
    # For each directory that is indexed the path is matched against these
    # names. If there is a match all items in the directory are marked as
    # compilations.
    # (changing this setting only takes effect after rescan, see the README)
    compilations = { "/Compilations" }

    # Compilations usually have many artists, and if you don't want every
    # artist to be listed when artist browsing in Remote, you can set
    # a single name which will be used for all music in the compilation dir
    # (changing this setting only takes effect after rescan, see the README)
    compilation_artist = "Various artists"

    # If your album and artist lists are cluttered, you can choose to hide
    # albums and artists with only one track. The tracks will still be
    # visible in other lists, e.g. songs and playlists. This setting
    # currently only works in some remotes.
#   hide_singles = false

    # Internet streams in your playlists will by default be shown in the
    # "Radio" library, like iTunes does. However, some clients (like
    # TunesRemote+) won't show the "Radio" library. If you would also like
    # to have them shown like normal playlists, you can enable this option.
#   radio_playlists = false

    # These are the default playlists. If you want them to have other names,
    # you can set it here.
#   name_library    = "Library"
#   name_music      = "Music"
#   name_movies     = "Movies"
#   name_tvshows    = "TV Shows"
#   name_podcasts   = "Podcasts"
#   name_audiobooks = "Audiobooks"
#   name_radio      = "Radio"

    # Artwork file names (without file type extension)
    # forked-daapd will look for jpg and png files with these base names
#   artwork_basenames = { "artwork", "cover", "Folder" }

    # Enable searching for artwork corresponding to each individual media
    # file instead of only looking for album artwork. This is disabled by
    # default to reduce cache size.
#   artwork_individual = false

    # File types the scanner should ignore
    # Non-audio files will never be added to the database, but here you
    # can prevent the scanner from even probing them. This might improve
    # scan time. By default .db, .ini, .db-journal and .pdf are ignored.
#   filetypes_ignore = { ".db", ".ini", ".db-journal", ".pdf" }

    # File paths the scanner should ignore
    # If you want to exclude files on a more advanced basis you can enter
    # one or more POSIX regular expressions, and any file with a matching
    # path will be ignored.
#   filepath_ignore = { "myregex" }

    # Disable startup file scanning
    # When forked-daapd starts it will do an initial file scan of your
    # library (and then watch it for changes). If you are sure your library
    # never changes while forked-daapd is not running, you can disable the
    # initial file scan and save some system ressources. Disabling this scan
    # may lead to forked-daapd's database coming out of sync with the
    # library. If that happens read the instructions in the README on how
    # to trigger a full rescan.
    filescan_disable = {{ library_filescan_disable }}

    # Should iTunes metadata override ours?
    itunes_overrides = {{ library_itunes_overrides }}

    # Should we import the content of iTunes smart playlists?
#   itunes_smartpl = false

    # Decoding options for DAAP clients
    # Since iTunes has native support for mpeg, mp4a, mp4v, alac and wav,
    # such files will be sent as they are. Any other formats will be decoded
    # to raw wav. If forked-daapd detects a non-iTunes DAAP client, it is
    # assumed to only support mpeg and wav, other formats will be decoded.
    # Here you can change when to decode. Note that these settings have no
    # effect on AirPlay.
    # Formats: mp4a, mp4v, mpeg, alac, flac, mpc, ogg, wma, wmal, wmav, aif, wav
    # Formats that should never be decoded
#   no_decode = { "format", "format" }

    # Formats that should always be decoded
#   force_decode = { "format", "format" }
}

# Local audio output
audio {
    # Name - used in the speaker list in Remote
#   nickname = "{{ audio_nickname }}"

    # Type of the output (alsa, pulseaudio or dummy)
   type = "{{ audio_type }}"

    # Audio PCM device name for local audio output - ALSA only
#   card = "default"

    # Mixer channel to use for volume control - ALSA only
    # If not set, PCM will be used if available, otherwise Master.
#   mixer = ""

    # Mixer device to use for volume control - ALSA only
    # If not set, the value for "card" will be used.
#   mixer_device = ""

    # Syncronization
    # If your local audio is out of sync with AirPlay, you can adjust this
    # value. Positive values correspond to moving local audio ahead,
    # negative correspond to delaying it. The unit is samples, where is
    # 44100 = 1 second. The offset must be between -44100 and 44100.
#   offset = 0
}

# Pipe output
# Allows forked-daapd to output audio data to a named pipe
#fifo {
#   nickname = "fifo"
#   path = "/path/to/fifo"
#}

# AirPlay/Airport Express device settings
# (make sure you get the capitalization of the device name right)
#airplay "My AirPlay device" {
    # forked-daapd's volume goes to 11! If that's more than you can handle
    # you can set a lower value here
#   max_volume = 11

    # AirPlay password
#   password = "s1kr3t"
#}

# Spotify settings (only have effect if Spotify enabled - see README/INSTALL)
#spotify {
    # Directory where user settings should be stored (credentials)
#   settings_dir = "/var/cache/forked-daapd/libspotify"

    # Cache directory
#   cache_dir = "/tmp"

    # Set preferred bitrate for music streaming
    # 0: No preference (default), 1: 96kbps, 2: 160kbps, 3: 320kbps
#   bitrate = 0

    # Your Spotify playlists will by default be put in a "Spotify" playlist
    # folder. If you would rather have them together with your other
    # playlists you can set this option to true.
#   base_playlist_disable = false

    # Spotify playlists usually have many artist, and if you don't want
    # every artist to be listed when artist browsing in Remote, you can set
    # the artist_override flag to true. This will use the compilation_artist
    # as album artist for Spotify items.
#   artist_override = false

    # Similar to the different artists in Spotify playlists, the playlist
    # items belong to different albums, and if you do not want every album
    # to be listed when browsing in Remote, you can set the album_override
    # flag to true. This will use the playlist name as album name for
    # Spotify items. Notice that if an item is in more than one playlist,
    # it will only appear in one album when browsing (in which album is
    # random).
#   album_override = false
#}

# MPD configuration (only have effect if MPD enabled - see README/INSTALL)
mpd {
    # TCP port to listen on for MPD client requests.
    # Default port is 6600, set to 0 to disable MPD support.
    port = {{ mpd_port }}

    # HTTP port to listen for artwork requests (only supported by some MPD
    # clients and will need additional configuration in the MPD client to
    # work). Set to 0 to disable serving artwork over http.
#   http_port = 0

    # By default forked-daapd will - like iTunes - clear the playqueue if
    # playback stops. Setting clear_queue_on_stop_disable to true will keep
    # the playlist like MPD does. Note that some dacp clients do not show
    # the playqueue if playback is stopped.
#   clear_queue_on_stop_disable = false
}

# SQLite configuration (allows to modify the operation of the SQLite databases)
# Make sure to read the SQLite documentation for the corresponding PRAGMA
# statements as changing them from the defaults may increase the possibility of
# database corruptions! By default the SQLite default values are used.
#sqlite {
    # Cache size in number of db pages for the library database
    # (SQLite default page size is 1024 bytes and cache size is 2000 pages)
#   pragma_cache_size_library = 2000

    # Cache size in number of db pages for the daap cache database
    # (SQLite default page size is 1024 bytes and cache size is 2000 pages)
#   pragma_cache_size_cache = 2000

    # Sets the journal mode for the database
    # DELETE (default), TRUNCATE, PERSIST, MEMORY, WAL, OFF
#   pragma_journal_mode = DELETE

    # Change the setting of the "synchronous" flag
    # 0: OFF, 1: NORMAL, 2: FULL (default)
#   pragma_synchronous = 2

    # Should the database be vacuumed on startup? (increases startup time,
    # but may reduce database size). Default is yes.
#   vacuum = yes
#}
